package com.chen.controller;

import com.chen.pojo.Leave;
import com.chen.service.LeaveService;
import com.chen.service.StudentService;
import com.chen.utils.Constants;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class LeaveController {
    @Autowired
    private LeaveService leaveService;
    @Autowired
    private StudentService studentService;
    @RequestMapping("/toLeaveInfo.html")
    public String toLeaveInfo(){
        return "/WEB-INF/pages/admin/leaveList";
    }

    @RequestMapping("getLeaveList.html")
    @ResponseBody
    public PageInfo<Leave> getLeaveList(@RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum){
        System.out.println(pageNum);
        PageHelper.startPage(pageNum, Constants.PAGESIZE);
        List<Leave> leaves = leaveService.getLeaveList();
        PageInfo<Leave> pageInfo = new PageInfo<Leave>(leaves);
        return pageInfo;
    }
}
